<?php

	//if(isset($_SESSION['idFun']) AND isset($_GET['id'])){

		$idusu = $_GET['id'];
		/////////////////////////////////////////////////////////////
		$servidor = 'localhost';
		$usuario = 'root';
		$senha = '';
		$banco = 'sadd';

		// Conecta-se ao banco de dados MySQL
		$mysqli = new mysqli($servidor, $usuario, $senha, $banco);


		////////////////////////////////////////////////////////////////

$sql2 = "SELECT DISTINCT ciclo.cic_ciclo FROM ciclo WHERE cic_usu_id = $idusu ";
$query2 = $mysqli->query($sql2);
while ($consulta = $query2->fetch_assoc()) {
        $auxiliar = $consulta['cic_ciclo'];

	
                
	$sql = "SELECT * FROM ciclo, funcionario WHERE ciclo.cic_usu_id = $idusu AND ciclo.cic_fun_id = funcionario.id AND  STRCMP(ciclo.cic_ciclo, '$auxiliar') = 0";

	$query = $mysqli->query($sql);
			
		while ($resultado = $query->fetch_assoc()) {
			$data[] = date('d/m/Y', strtotime($resultado['cic_datainicio']));
			$opcao[] = $resultado['cic_conceito'];
			$nomeOpcao = "Conceito";
			$unidade = "Pontos";
			$nome = $resultado['fun_nome'];
		}		
	

	
	
	/* CAT:Bar Chart */
	
	/* pChart library inclusions */
	include_once("pChart/class/pData.class.php");
	include_once("pChart/class/pDraw.class.php");
	include_once("pChart/class/pImage.class.php");
 
  /* Create and populate the pData object */
 $MyData = new pData();  
 $MyData->addPoints($opcao,$nomeOpcao);
 $MyData->setSerieWeight($nomeOpcao,3); 
 $MyData->setAxisName(0,$unidade);
 
 $MyData->addPoints($data,"Labels");
 $MyData->setSerieDescription("Labels","Data");
 $MyData->setAbscissa("Labels");

 /* Create the pChart object */
 $myPicture = new pImage(600,300,$MyData);

 /* Turn of Antialiasing */
 $myPicture->Antialias = FALSE;

 /* Draw the background */

 $Settings = array("R"=>89, "G"=>247, "B"=>232, "Dash"=>1, "DashR"=>109, "DashG"=>267, "DashB"=>252);
 $myPicture->drawFilledRectangle(0,0,600,300,$Settings);

 /* Overlay with a gradient */
 $Settings = array("StartR"=>29, "StartG"=>107, "StartB"=>89, "EndR"=>138, "EndG"=>26, "EndB"=>56, "Alpha"=>50);
 $myPicture->drawGradientArea(0,0,600,300,DIRECTION_VERTICAL,$Settings);

 /* Add a border to the picture */
 $myPicture->drawRectangle(0,0,599,299,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>20));
 
 /* Write the chart title */ 
$myPicture->setFontProperties(array("FontName"=>"pChart/fonts/Forgotte.ttf","FontSize"=>14));
$TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE
, "R"=>255, "G"=>255, "B"=>255);
$myPicture->drawText(50,10,"Evolução",$TextSettings);
$myPicture->setShadow(FALSE);

 /* Set the default font */
 $myPicture->setFontProperties(array("FontName"=>"pChart/fonts/Bedizen.ttf","FontSize"=>9,"R"=>0,"G"=>0,"B"=>0));
 /* Define the chart area */
 $myPicture->setGraphArea(60,40,570,250);

 /* Draw the scale */
$Settings = array("Pos"=>SCALE_POS_LEFTRIGHT
, "Mode"=>SCALE_MODE_FLOATING
, "LabelingMethod"=>LABELING_ALL
, "GridR"=>10, "GridG"=>10, "GridB"=>10, "GridAlpha"=>50, "TickR"=>0, "TickG"=>0, "TickB"=>0, "TickAlpha"=>50, "LabelRotation"=>0, "CycleBackground"=>1, "DrawXLines"=>1, "DrawSubTicks"=>1, "SubTickR"=>235, "SubTickG"=>0, "SubTickB"=>0, "SubTickAlpha"=>50, "DrawYLines"=>ALL);
$myPicture->drawScale($Settings);

 /* Turn on Antialiasing */
 $myPicture->Antialias = TRUE;

 /* Enable shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>50,"G"=>50,"B"=>50,"Alpha"=>10));
				  
 /* Draw the line chart */
 $myPicture->drawLineChart();
 $myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>1,"Surrounding"=>-20,"BorderAlpha"=>20)); 
  /* Write the chart legend */
 $myPicture->drawLegend(110,9,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL,"FontR"=>255,"FontG"=>255,"FontB"=>255)); 
 $i ++;
 $myPicture->Render("$i.png"); 
 
 ?>
<div>
    <p>Especialista : <?php echo $nome; ?></p>
	<p>Tratamento : <?php echo $auxiliar; ?></p>
<img class="" src="<?php echo $i ?>.png" />
</div>
        <?php  
		$data= array();
		$opcao= array();
		}?>
